//
//  UIView+FCHelper.m
//  playcar
//
//  Created by 游庆盛 on 2018/5/30.
//  Copyright © 2018年 ljkj. All rights reserved.
//

#import "UIView+FCHelper.h"

@implementation UIView (FCHelper) 

- (CGFloat)cornerRadius {
    return self.layer.cornerRadius;
}

- (void)setCornerRadius:(CGFloat)cornerRadius {
    if (self.layer.cornerRadius != cornerRadius) {
        self.layer.cornerRadius = cornerRadius;
        self.layer.masksToBounds = YES;
    }
}

@end


@implementation UIView (LoadFromXIB)

- (BOOL)isFromXIB {
    return [objc_getAssociatedObject(self, _cmd) boolValue];
}

+ (instancetype)viewFromXIB {
    UIView *view = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].firstObject;
    if (view) {
        objc_setAssociatedObject(self, @selector(isFromXIB), @(YES), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    }
    return view;
}

@end
